<?php
    include_once '../module/inventory/config.inc.php';
    $inventory_config = new config();
    
    



	$id=$_GET['id']?$_GET['id']:NULL;
	$key=$_GET['key']?$_GET['key']:NULL;
	$catid=$_GET['catid']?$_GET['catid']:NULL;
	
	if(!empty($key))
		$scl.=" and ( title like '%$key%' )";
	if(!empty($catid))
		$scl.=" and (path like '%,$catid,%')";
	if(!empty($id)){
	    if (!preg_match("/[^\d,]/", $id)){
	       $scl.=" and id in ($id)";
	    }
	}
		
	$sql="SELECT * FROM ".$inventory_config->db_prefix."products where 1 $scl order by id asc";
	//====================
	include_once("../includes/page_utf_class.php");
	$page = new Page;
	$page->listRows=10;
	if (!$page->__get('totalRows')){
		$db->query($sql);
		$page->totalRows = $db->num_rows();
	}
	$sql .= "  limit ".$page->firstRow.",".$page->listRows;
	$de['page'] = $page->prompt();
	//=====================
	$db->query($sql);
	$de['list']=$db->getRows();
	$tpl->assign("de",$de);
	
	$tpl->assign("config",$config);
	$tpl->display("inventory_list.htm");
	
?>